package siam.ui;

import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 * Class which represent the Force Panel
 * @author Motassim Saad
 * @see {@link DirectionLabel}
 *
 */
public class ForcePanel extends JPanel {

	private DirectionLabel topForce;
	private DirectionLabel leftForce;
	private DirectionLabel rightForce;
	private DirectionLabel bottomForce;

	/**
	 * Create the panel.
	 */
	public ForcePanel() {
		setLayout(new GridLayout(3, 3, 0, 0));

		add(new JLabel(""));

		topForce = new DirectionLabel(Force.HAUT);
		add(topForce);

		add(new JLabel(""));

		leftForce = new DirectionLabel(Force.GAUCHE);
		leftForce.setVerticalAlignment(SwingConstants.TOP);
		add(leftForce);

		add(new JLabel(""));

		rightForce = new DirectionLabel(Force.DROITE);
		add(rightForce);

		add(new JLabel(""));

		bottomForce = new DirectionLabel(Force.BAS);
		add(bottomForce);

		add(new JLabel(""));
		setForceActivate(null);

	}
	/**
	 * Set the force activate
	 * @param {@link Force}
	 */
	void setForceActivate(Force force) {
		topForce.desactivate();
		leftForce.desactivate();
		rightForce.desactivate();
		bottomForce.desactivate();
		if (force != null) {
			switch (force) {

			case HAUT:
				topForce.activate();
				break;

			case BAS:
				bottomForce.activate();
				break;

			case DROITE:
				rightForce.activate();
				break;

			case GAUCHE:
				leftForce.activate();
				break;
			}
			this.repaint();
		}
	}

	public DirectionLabel getBottomForce() {
		return bottomForce;
	}

	public DirectionLabel getRightForce() {
		return rightForce;
	}

	public DirectionLabel getLeftForce() {
		return leftForce;
	}

	public DirectionLabel getTopForce() {
		return topForce;
	}

}
